package com.homework.service;/**
 * @author： li
 * @date： 2021-05-18 18:25
 * @version 1.0
 */

import com.homework.bin.user;
import com.homework.dao.userdao;
import com.homework.util.DBUtil1;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @author： Administrator
 * @date： 2021-05-18 18:25
 * @version 1.0
 */
public class userservice {
    user us=new user();
    DBUtil1 db=new DBUtil1();
    //用户注册
    public int register(user user){
        int i=0;
        try {
            i= userdao.insert(user);
        } catch (SQLException | ClassNotFoundException e) {
            e.printStackTrace();
        }
        return i;
    }
    //用户登入
    public int login(user user) throws SQLException {
        ResultSet rs=null;
        try {
           rs= userdao.selectbyusernameanpassword(user);
        } catch (SQLException | ClassNotFoundException e) {
            e.printStackTrace();
        }
        if(rs.next()){
            return 1;
        }else {
        return 0;
        }
    }
    //用户修改
    public void update(){

    }
    //用户删除
    public void delete(){

    }
}
